﻿using System.Threading;
using NUnit.Framework;
using Rainbow.ObjectFlow.Framework;
using Shouldly;

namespace objectflow.core.tests.integration
{
    [TestFixture]
    public class ParallelTests
    {
        [Test]
        public void Should_Merge_at_end()
        {
            var workflow = Workflow<string>.Definition()
                                           .Do(x => x += Thread.CurrentThread.ManagedThreadId + "-O01")
                                           .And.Do(x => x += Thread.CurrentThread.ManagedThreadId + "-O02")
                                           .Then().Do(x => x += Thread.CurrentThread.ManagedThreadId + "-O03");


            var result = workflow.Start("");
            workflow.Context.ShouldNotBeEmpty();
            result.ShouldNotBeEmpty();

            result.ShouldEndWith("-O03");

        }

        [Test]
        public void Should_do_x()
        {
            var workflow = Workflow<string>.Definition().Do(x => x + "z");
            var result = workflow.Start();
            workflow.Context.ShouldBe("z");
            result.ShouldBe("z");
        }

    }
}